package router

import (
  "net/http"
  "github.com/gin-gonic/gin"
  "go_part/service"
  docs "go_part/docs"
  ginSwagger "github.com/swaggo/gin-swagger" // gin-swagger middleware
  swaggerfiles "github.com/swaggo/files"
)

func Router() *gin.Engine{
	r := gin.Default()
	docs.SwaggerInfo.BasePath = ""
	r.GET("swagger/*any",ginSwagger.WrapHandler(swaggerfiles.Handler))

	//r.Static("/asset","asset/")
	// r.LoadHTMLGlob("view/**/*")

	//首页
	// 将本地的"css"文件夹映射到"/css"路径
	r.Static("/css", "./dist/css")
	// 将本地的"js"文件夹映射到"/js"路径
	r.Static("/js", "./dist/js")
	// 将本地的"fonts"文件夹映射到"/fonts"路径
	r.Static("/fonts", "./dist/fonts")

	r.Use(func(c *gin.Context) {
        c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
        c.Writer.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
        c.Writer.Header().Set("Access-Control-Allow-Headers", "Origin, Content-Type, Accept, Authorization")

        if c.Request.Method == "OPTIONS" {
            c.AbortWithStatus(http.StatusNoContent)
            return
        }
        c.Next()
    })

	r.StaticFS("/login", gin.Dir("./dist", false))

	r.GET("/index",service.GetIndex)
	r.GET("/user/getUserList",service.GetUserList)
	r.GET("/user/CreateUser",service.CreateUser)
	r.GET("/user/DeleteUser",service.DeleteUser)
	r.POST("/user/UpdateUser",service.UpdateUser)
	r.POST("/user/FindUserByNameAndPwd",service.FindUserByNameAndPwd)

	r.GET("/user/SendMsg",service.SendMsg)
	r.GET("/user/SendUserMsg",service.SendUserMsg)

	r.GET("/user/SearchFrient",service.SearchFrient)
	r.GET("/user/AddFrient",service.AddFriend)

	//创建群
	r.GET("/user/CreateCommunity",service.CreateCommunity)
	//群列表
	r.GET("/user/LoadCommunity",service.LoadCommunity)
	//加入群
	r.GET("/user/JoinGroup",service.JoinGroup)
	
	//创建公司
	r.GET("/company/CreateCompany",service.CreateCompany)
	//公司列表
	r.GET("/company/GetCompanyList",service.GetCompanyList)
	//删除公司
	r.GET("/company/DeleteCompany",service.DeleteCompany)
	//更新公司
	r.POST("/company/UpdateCompany",service.UpdateCompany)
	//检索公司
	r.GET("/company/FindCompanyByID",service.FindCompanyByID)
	//检索公司
	r.GET("/company/FindCompanyByIDAndPassword",service.FindCompanyByIDAndPassword)
	
	//校验邀请码
	r.GET("/company/InviteNumber",service.InviteNumber)

		//创建公司
		r.GET("/company/CreateLevelType",service.CreateLevelType)
		//公司列表
		r.GET("/company/GetLevelTypeList",service.GetLevelTypeList)
		//删除公司
		r.GET("/company/DeleteLevelType",service.DeleteLevelType)
		//更新公司
		r.POST("/company/UpdateLevelType",service.UpdateLevelType)
		//公司列表
		r.GET("/company/FindLevelTypeByID",service.FindLevelTypeByID)
		//公司列表
		r.GET("/company/FindLevelTypeByCompanyID",service.FindLevelTypeByCompanyID)

		//创建公司
		r.GET("/company/CreateDeparkment",service.CreateDeparkment)
		//公司列表
		r.GET("/company/GetDeparkmentList",service.GetDeparkmentList)
		//删除公司
		r.GET("/company/DeleteDeparkment",service.DeleteDeparkment)
		//更新公司
		r.POST("/company/UpdateDeparkment",service.UpdateDeparkment)
		//检索部门
		r.GET("/company/FindDeparkmentByCompanyID",service.FindDeparkmentByCompanyID)

		//创建公司
		r.GET("/company/CreateLevelLocal",service.CreateLevelLocal)
		//公司列表
		r.GET("/company/GetLevelLocalList",service.GetLevelLocalList)
		//删除公司
		r.GET("/company/DeleteLevelLocal",service.DeleteLevelLocal)
		//更新公司
		r.POST("/company/UpdateLevelLocal",service.UpdateLevelLocal)
		//检索区域
		r.GET("/company/FindLevelLocalByTypeIDAndCompanyID",service.FindLevelLocalByTypeIDAndCompanyID)

		//创建公司
		r.GET("/company/CreateLevelDevice",service.CreateLevelDevice)
		//公司列表
		r.GET("/company/GetLevelDeviceList",service.GetLevelDeviceList)
		//删除公司
		r.GET("/company/DeleteLevelDevice",service.DeleteLevelDevice)
		//更新公司
		r.POST("/company/UpdateLevelDevice",service.UpdateLevelDevice)
		//检索设备
		r.GET("/company/FindLevelDeviceByTypeIDAndCompanyID",service.FindLevelDeviceByTypeIDAndCompanyID)
		
	//创建公司
	r.GET("/approval/CreateApprovalType",service.CreateApprovalType)
	//公司列表
	r.GET("/approval/GetApprovalTypeList",service.GetApprovalTypeList)
	//删除公司
	r.GET("/approval/DeleteApprovalType",service.DeleteApprovalType)
	//更新公司
	r.POST("/approval/UpdateApprovalType",service.UpdateApprovalType)
	//检索审批
	r.GET("/approval/FindApprovalTypeByCompanyID",service.FindApprovalTypeByCompanyID)

		//创建公司
		r.GET("/approval/GetApprovalStepModuleList",service.GetApprovalStepModuleList)
		//公司列表
		r.GET("/approval/CreateApprovalStepModule",service.CreateApprovalStepModule)
		//删除公司
		r.GET("/approval/DeleteApprovalStepModule",service.DeleteApprovalStepModule)
		//更新公司
		r.POST("/approval/UpdateApprovalStepModule",service.UpdateApprovalStepModule)
		//检索审批模型
		r.GET("/approval/FindApprovalStepModuleByCompanyID",service.FindApprovalStepModuleByCompanyID)
		

		//创建公司
		r.GET("/approval/CreateApprovalStep",service.CreateApprovalStep)
		//公司列表
		r.GET("/approval/GetApprovalStepList",service.GetApprovalStepList)
		//删除公司
		r.GET("/approval/DeleteApprovalStep",service.DeleteApprovalStep)
		//更新公司
		r.POST("/approval/UpdateApprovalStep",service.UpdateApprovalStep)
		//删除公司
		r.GET("/approval/FindApprovalStepByCompanyID",service.FindApprovalStepByCompanyID)
		

		//创建公司
		r.GET("/approval/CreateApprovalLocal",service.CreateApprovalLocal)
		//公司列表
		r.GET("/approval/GetApprovalLocalList",service.GetApprovalLocalList)
		//删除公司
		r.GET("/approval/DeleteApprovalLocal",service.DeleteApprovalLocal)
		//更新公司
		r.POST("/approval/UpdateApprovalLocal",service.UpdateApprovalLocal)
		//删除公司
		r.GET("/approval/FindApprovalLocalByApprovalID",service.FindApprovalLocalByApprovalID)
		

		//创建公司
		r.GET("/approval/CreateApprovalSelfDefine",service.CreateApprovalSelfDefine)
		//公司列表
		r.GET("/approval/GetApprovalSelfDefineList",service.GetApprovalSelfDefineList)
		//删除公司
		r.GET("/approval/DeleteApprovalSelfDefine",service.DeleteApprovalSelfDefine)
		//更新公司
		r.POST("/approval/UpdateApprovalSelfDefine",service.UpdateApprovalSelfDefine)
		//删除公司
		r.GET("/approval/FindApprovalSelfDefineByStepID",service.FindApprovalSelfDefineByStepID)
		

	//创建公司
	r.GET("/device/CreatePositionDevice",service.CreatePositionDevice)
	//公司列表
	r.GET("/device/GePositionDeviceList",service.GePositionDeviceList)
	//删除公司
	r.GET("/device/DeletePositionDevice",service.DeletePositionDevice)
	//更新公司
	r.POST("/device/UpdatePositionDevice",service.UpdatePositionDevice)	
	//检索点位设备
	r.GET("/device/FindPositionDeviceByTypeIDAndCompanyID",service.FindPositionDeviceByTypeIDAndCompanyID)
	

	//创建公司
	r.GET("/device/robot/CreateRobotDevice",service.CreateRobotDevice)
	//公司列表
	r.GET("/device/robot/GetRobotDeviceList",service.GetRobotDeviceList)
	//删除公司
	r.GET("/device/robot/DeleteRobotDevice",service.DeleteRobotDevice)
	//更新公司
	r.POST("/device/robot/UpdateRobotDevice",service.UpdateRobotDevice)	
	//检索机器人设备
	r.GET("/device/FindRobotDeviceByTypeIDAndCompanyID",service.FindRobotDeviceByTypeIDAndCompanyID)

		//创建公司
		r.GET("/device/robot/CreateFunctionBasic",service.CreateFunctionBasic)
		//公司列表
		r.GET("/device/robot/GetFunctionBasicList",service.GetFunctionBasicList)
		//删除公司
		r.GET("/device/robot/DeleteFunctionBasic",service.DeleteFunctionBasic)
		//更新公司
		r.POST("/device/robot/UpdateFunctionBasic",service.UpdateFunctionBasic)	
		//检索功能
		r.GET("/device/FindFunctionBasicByTypeIDAndCompanyID",service.FindFunctionBasicByTypeIDAndCompanyID)

		//创建公司
		r.GET("/device/robot/CreateLimitBasic",service.CreateLimitBasic)
		//公司列表
		r.GET("/device/robot/GetLimitBasicList",service.GetLimitBasicList)
		//删除公司
		r.GET("/device/robot/DeleteLimitBasic",service.DeleteLimitBasic)
		//更新公司
		r.POST("/device/robot/UpdateLimitBasic",service.UpdateLimitBasic)	
		//检索约束
		r.GET("/device/FindLimitBasicByTypeIDAndCompanyID",service.FindLimitBasicByTypeIDAndCompanyID)
		

	//创建公司
	r.GET("/device/fly/CreateFlyDeviceBasic",service.CreateFlyDeviceBasic)
	//公司列表
	r.GET("/device/fly/GetFlyDeviceBasicList",service.GetFlyDeviceBasicList)
	//删除公司
	r.GET("/device/fly/DeleteFlyDeviceBasic",service.DeleteFlyDeviceBasic)
	//更新公司
	r.POST("/device/fly/UpdateFlyDeviceBasic",service.UpdateFlyDeviceBasic)	
	//检索无人机
	r.GET("/device/FindFlyDeviceByTypeIDAndCompanyID",service.FindFlyDeviceByTypeIDAndCompanyID)
	

		//创建公司
		r.GET("/device/fly/CreateAirportInfo",service.CreateAirportInfo)
		//公司列表
		r.GET("/device/fly/GetAirportInfoList",service.GetAirportInfoList)
		//删除公司
		r.GET("/device/fly/DeleteAirportInfo",service.DeleteAirportInfo)
		//更新公司
		r.POST("/device/fly/UpdateAirportInfo",service.UpdateAirportInfo)
		//检索机场
		r.GET("/device/FindAirportByTypeIDAndCompanyID",service.FindAirportByTypeIDAndCompanyID)	

		//创建公司
		r.GET("/device/fly/CreatePositionInfo",service.CreatePositionInfo)
		//公司列表
		r.GET("/device/fly/GetPositionInfoList",service.GetPositionInfoList)
		//删除公司
		r.GET("/device/fly/DeletePositionInfo",service.DeletePositionInfo)
		//更新公司
		r.POST("/device/fly/UpdatePositionInfo",service.UpdatePositionInfo)	
		//检索点区
		r.GET("/device/FindPositionInfoByTypeIDAndCompanyID",service.FindPositionInfoByTypeIDAndCompanyID)

	//上传
	r.POST("/attach/upload",service.Upload)
	

	return r
}